package com.feituan.wx.controller;

import com.feituan.core.constants.Constant;
import com.feituan.core.pojo.entity.Advice;
import com.feituan.core.pojo.request.AdvicePageReq;
import com.feituan.core.pojo.request.PageBaseReq;
import com.feituan.core.pojo.response.Response;
import com.feituan.core.pojo.response.page.PageData;
import com.feituan.core.service.IAdviceBizService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;


public class BaseController {

    protected Response<Boolean> response(boolean result){
        Response<Boolean> response = new Response<Boolean>();
        if (result) {
            response.setData(true);
            response.setCode(Constant.RESPONSE_SUCCESS_CODE);
        } else {
            response.setData(false);
            response.setCode(Constant.RESPONSE_NOT_SUCCESS_CODE);
        }
        return response;
    }

    protected void setDefaultPageParameters(PageBaseReq req){
        if(req.getPage()==null){
            req.setPage(1);
        }
        if(req.getLimit() == null){
            req.setLimit(10);
        }
    }
}
